package com.mitac.mcd.mobiletracking.servlets;


import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import com.mitac.mcd.mobiletracking.managementclient.impl.DBConnection;


public class initParameters extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4907241530691960652L;
	
	public static final Properties ConfigProperties = new Properties();
	public static final Properties jdbcProperties = new Properties();
	
	public void init(ServletConfig config) throws ServletException {
        super.init(config);
        /****************get all properties file data to cache****************/
        InputStream ConfigInputStream = getClass().getClassLoader().getResourceAsStream("config.properties");
        InputStream jdbcInputStream = getClass().getClassLoader().getResourceAsStream("jdbc.properties");
        try {
			ConfigProperties.load(ConfigInputStream);
			jdbcProperties.load(jdbcInputStream);
		} catch (IOException e) {
			e.printStackTrace();
			System.out.println("ConfigProperties加载配置属性失败，请检查...");
		}
		try {
			DBConnection.initConnection();
		} catch (Exception e) {
			System.out.println("数据库连接池初始化发生异常:"+e);
			System.out.println("initParameters失败...");
		}
		System.out.println("Mobile Tracking Socket Server started...");
		//JSocketServerImpl jsi = new JSocketServerImpl();
		//System.out.println(jsi.getExceptionStatisticPeriod("20101201", "20101203"));
    }
	
}
